/**
 * Copyright (c) 2013-Now http://jeesite.com All rights reserved.
 */
package com.jeesite.modules.pay.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.jeesite.common.collect.ListUtils;
import com.jeesite.common.entity.DataEntity;
import com.jeesite.common.mybatis.annotation.Column;
import com.jeesite.common.mybatis.annotation.JoinTable;
import com.jeesite.common.mybatis.annotation.JoinTable.Type;
import com.jeesite.common.mybatis.annotation.Table;
import com.jeesite.common.mybatis.mapper.query.QueryType;
import com.jeesite.modules.base.entity.supplier.Supplier;
import com.jeesite.modules.base.entity.taccount.Taccount;
import com.jeesite.modules.order.entity.serviceorder.ServiceOrder;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.util.Date;
import java.util.List;

/**
 * 付款单Entity
 * @author wsm
 * @version 2021-03-16
 */
@Table(name="t_payment", alias="a", columns={
		@Column(name="payment_id", attrName="paymentId", label="付款单ID", isPK=true),
		@Column(name="payment_code", attrName="paymentCode", label="编号", queryType=QueryType.LIKE),
		@Column(name="supplier_id", attrName="supplierId", label="供应商"),
		@Column(name="date", attrName="date", label="日期"),
		@Column(name="status1", attrName="status1", label="状态"),
		@Column(name="service_order_id", attrName="serviceOrderId", label="服务订单"),
		//@Column(name="ap_code", attrName="apCode", label="应付单", isQuery=false),
		@Column(name="payment_amount", attrName="paymentAmount", label="付款/核销金额", isQuery=false),
		@Column(name="currency", attrName="currency", label="币种", isQuery=false),
		@Column(name="payment_method", attrName="paymentMethod", label="付款方式", isQuery=false),
		@Column(name="payment_bank", attrName="paymentBank", label="付款银行", isQuery=false),
		@Column(name="create_by", attrName="createBy", label="创建者", isUpdate=false, isQuery=false),
		@Column(name="create_date", attrName="createDate", label="创建时间", isUpdate=false, isQuery=false),
		@Column(name="update_by", attrName="updateBy", label="更新者", isQuery=false),
		@Column(name="update_date", attrName="updateDate", label="更新时间", isQuery=false),
		@Column(name="remarks", attrName="remarks", label="备注信息", queryType=QueryType.LIKE),
	}, joinTable= {
		@JoinTable(type = Type.LEFT_JOIN, entity = Supplier.class, attrName = "supplier", alias = "b",
				on = "b.supplier_id = a.supplier_id", columns = {
				@Column(name = "supplier_id", label = "供货外商编码", isPK = true),
				@Column(name = "supplier_name", label = "供货外商名称", isQuery = false),
		}),
		@JoinTable(type = Type.LEFT_JOIN, entity = ServiceOrder.class, attrName = "serviceOrder", alias = "c",
				on = "c.service_order_id = a.service_order_id", columns = {
				@Column(name = "service_order_id", label = "服务单id", isPK = true),
				@Column(name = "service_order_code", label = "服务单编码", isQuery = false),
		}),
		@JoinTable(type = Type.LEFT_JOIN, entity = Taccount.class, attrName = "taccount", alias = "d",
				on = "d.account_id = a.payment_bank", columns = {
				@Column(name = "account_id", label = "银行id", isPK = true),
				@Column(name = "account_name", label = "银行名称"),
		})
},orderBy="a.update_date DESC"
)
public class Tpayment extends DataEntity<Tpayment> {
	
	private static final long serialVersionUID = 1L;
	private String paymentId;		// 付款单ID
	private String paymentCode;		// 编号
	private String supplierId;		// 供应商

	private Date date;		// 日期
	private String status1;		// 状态
	private String serviceOrderId;		// 服务订单
	private Double paymentAmount;		// 付款/核销金额
	private String currency;		// 币种
	private String paymentMethod;		// 付款方式
	private String paymentBank;		// 付款银行
	private Supplier supplier;//供应商
	private String remarks;
	private String apCode;
	private ServiceOrder serviceOrder;
	private Taccount taccount;

	public Taccount getTaccount() {
		return taccount;
	}

	public void setTaccount(Taccount taccount) {
		this.taccount = taccount;
	}

	public ServiceOrder getServiceOrder() {
		return serviceOrder;
	}

	public void setServiceOrder(ServiceOrder serviceOrder) {
		this.serviceOrder = serviceOrder;
	}

	public String getApCode() {
		return apCode;
	}

	public void setApCode(String apCode) {
		this.apCode = apCode;
	}

	public Supplier getSupplier() {
		return supplier;
	}

	public void setSupplier(Supplier supplier) {
		this.supplier = supplier;
	}

	@Override
	public String getRemarks() {
		return remarks;
	}

	@Override
	public void setRemarks(String remarks) {
		this.remarks = remarks;
	}

	private List<TpaymentDetail> tpaymentDetailList = ListUtils.newArrayList();		// 子表列表
	
	public Tpayment() {
		this(null);
	}

	public Tpayment(String id){
		super(id);
	}
	
	public String getPaymentId() {
		return paymentId;
	}

	public void setPaymentId(String paymentId) {
		this.paymentId = paymentId;
	}
	
	@Length(min=0, max=100, message="编号长度不能超过 100 个字符")
	public String getPaymentCode() {
		return paymentCode;
	}

	public void setPaymentCode(String paymentCode) {
		this.paymentCode = paymentCode;
	}
	
	@Length(min=0, max=64, message="供应商长度不能超过 64 个字符")
	public String getSupplierId() {
		return supplierId;
	}

	public void setSupplierId(String supplierId) {
		this.supplierId = supplierId;
	}
	
	@JsonFormat(pattern = "yyyy-MM-dd")
	@NotNull(message="日期不能为空")
	public Date getDate() {
		return date;
	}

	public void setDate(Date date) {
		this.date = date;
	}
	
	@Length(min=0, max=1, message="状态长度不能超过 1 个字符")
	public String getStatus1() {
		return status1;
	}

	public void setStatus1(String status1) {
		this.status1 = status1;
	}
	
	@Length(min=0, max=64, message="服务订单长度不能超过 64 个字符")
	public String getServiceOrderId() {
		return serviceOrderId;
	}

	public void setServiceOrderId(String serviceOrderId) {
		this.serviceOrderId = serviceOrderId;
	}
	


	public Double getPaymentAmount() {
		return paymentAmount;
	}

	public void setPaymentAmount(Double paymentAmount) {
		this.paymentAmount = paymentAmount;
	}
	
	@NotBlank(message="币种不能为空")
	@Length(min=0, max=2, message="币种长度不能超过 2 个字符")
	public String getCurrency() {
		return currency;
	}

	public void setCurrency(String currency) {
		this.currency = currency;
	}
	
	@NotBlank(message="付款方式不能为空")
	@Length(min=0, max=2, message="付款方式长度不能超过 2 个字符")
	public String getPaymentMethod() {
		return paymentMethod;
	}

	public void setPaymentMethod(String paymentMethod) {
		this.paymentMethod = paymentMethod;
	}
	
	@Length(min=0, max=50, message="付款银行长度不能超过 50 个字符")
	public String getPaymentBank() {
		return paymentBank;
	}

	public void setPaymentBank(String paymentBank) {
		this.paymentBank = paymentBank;
	}
	
	public Date getDate_gte() {
		return sqlMap.getWhere().getValue("date", QueryType.GTE);
	}

	public void setDate_gte(Date date) {
		sqlMap.getWhere().and("date", QueryType.GTE, date);
	}
	
	public Date getDate_lte() {
		return sqlMap.getWhere().getValue("date", QueryType.LTE);
	}

	public void setDate_lte(Date date) {
		sqlMap.getWhere().and("date", QueryType.LTE, date);
	}
	
	public List<TpaymentDetail> getTpaymentDetailList() {
		return tpaymentDetailList;
	}

	public void setTpaymentDetailList(List<TpaymentDetail> tpaymentDetailList) {
		this.tpaymentDetailList = tpaymentDetailList;
	}
	
}